<cfparam name="attributes.KalendarRequest" type="any">
<cfparam name="Attributes.view" type="string" default="list" />
<cfset variables.dayOfWeek = dayOfWeek(attributes.KalendarRequest.getLinkDate()) />
<cfset firstDay = createODBCDate(dateAdd('d', dayOfWeek, attributes.KalendarRequest.getLinkDate())) />
<!--- BEGIN: optionBar --->
<div id="optionBar" class="clearfix">
<cfswitch expression="#attributes.view#">
	<cfcase value="day">
		<script type="text/javascript">
			function reloadView() {
				changeDay();
			}
		</script>
		<!--- DATE SELECTOR --->
		<div id="dateMenu">
		<cfform method="post" action="#cgi.SCRIPT_NAME#" id="dateSelectForm">
			<input type="hidden" name="view" value="<cfoutput>#attributes.view#</cfoutput>" />
			<input type="hidden" name="categoryID" value="<cfoutput>#attributes.KalendarRequest.getCategoryID()#</cfoutput>" />
			<!--- DAY SELECTOR --->
			<cfoutput>
			<select name="linkdate" class="calendarSelectBoxes" onchange="changeDay();">
				<cfloop index="loopcount" from="-10" to="10">
				<cfset optionday = dateadd('d', loopcount, firstday)>
				<option<cfif attributes.KalendarRequest.getLinkDate() eq optionday>  selected="selected"</cfif>><cfoutput>#dateformat(optionday, 'mmmm d, yyyy')#</cfoutput></option></cfloop>
			</select>
			</cfoutput>
		</cfform>
		</div>
		
		
		<cfif Month(Now()) neq Month(attributes.KalendarRequest.getLinkDate())>
		<!--- CURRENT MONTH BUTTON --->
		<div id="currentButton">
		<cfform action="#cgi.SCRIPT_NAME#" method="post" id="daySelector">
		<cfoutput>
			<input type="hidden" name="LinkDate" value="#DateFormat(Now(), 'm/d/yyyy')#" id="Link2Date" />
			<input type="hidden" name="categoryID" value="<cfoutput>#attributes.KalendarRequest.getCategoryID()#</cfoutput>" />
			<input type="hidden" name="View" value="<cfoutput>#attributes.view#</cfoutput>" />
			<input type="submit" name="submit" value=" current month " class="optionBarButton" /></cfoutput>
		</cfform>
		</div>
		</cfif>
	</cfcase>
	
	<cfcase value="month">
		<script type="text/javascript">
			function reloadView() {
				changeDate();
			}
		</script>
		<!--- DATE SELECTOR --->
		<div id="dateMenu">
		<cfform method="post" action="#cgi.SCRIPT_NAME#" id="dateSelectForm">
			<input type="hidden" name="view" value="<cfoutput>#attributes.view#</cfoutput>" />
			<input type="hidden" name="categoryID" value="<cfoutput>#attributes.KalendarRequest.getCategoryID()#</cfoutput>" />
			<input type="hidden" name="LinkDate" value="" />
			<!--- MONTH SELECTOR --->
			<select name="LinkMonth" onchange="changeDate();">
				<cfloop from="1" to="12" index="i">
				<cfoutput>
				<option value="#MonthAsString(i)#"<cfif Month(attributes.KalendarRequest.getLinkDate()) eq i> selected="selected"</cfif>>#MonthAsString(i)#</option>
				</cfoutput>
				</cfloop>
			</select>
			<!--- YEAR SELECTOR --->
			<select name="LinkYear" onchange="changeDate();">
			<cfloop index="LoopCount" from="-7" to="50">
				<cfset OptionYear = Year(attributes.KalendarRequest.getLinkDate()) + LoopCount>
				<cfoutput><option value="#OptionYear#"<cfif NOT LoopCount> selected="selected"</cfif>>#OptionYear#</option></cfoutput>
			</cfloop>
			</select>
		</cfform>
		</div>
		
		
		<cfif Month(Now()) neq Month(attributes.KalendarRequest.getLinkDate())>
		<!--- CURRENT MONTH BUTTON --->
		<div id="currentButton">
		<cfform action="#cgi.SCRIPT_NAME#" method="post" id="viewMonthForm">
		<cfoutput>
			<input type="hidden" name="LinkDate" value="#DateFormat(Now(), 'm/d/yyyy')#" id="Link2Date" />
			<input type="hidden" name="categoryID" value="<cfoutput>#attributes.KalendarRequest.getCategoryID()#</cfoutput>" />
			<input type="hidden" name="View" value="<cfoutput>#attributes.view#</cfoutput>" />
			<input type="submit" name="submit" value=" current month " class="optionBarButton" /></cfoutput>
		</cfform>
		</div>
		</cfif>
	</cfcase>
	
	<cfcase value="list">
		<cfoutput>
		<script type="text/javascript">
			function reloadView() {
				location.href = '#KalendarConfig.getKalendarURLPath()#index.cfm?linkDate=#DateFormat(attributes.KalendarRequest.getLinkDate(),"mm/dd/yyyy")#&view=list&amp;categoryID=#attributes.KalendarRequest.getCategoryID()#';
			}
		</script>
		</cfoutput>
	</cfcase>
	
	<cfcase value="weeklist,week">
		<script type="text/javascript">
			function reloadView() {
				changeWeek();
			}
		</script><!--- DATE SELECTOR --->
		<div id="dateMenu">
		<cfform method=post action="#cgi.SCRIPT_NAME#" id="weekSelector">
			<input type="hidden" name="view" value="<cfoutput>#attributes.view#</cfoutput>" />
			<input type="hidden" name="categoryID" value="<cfoutput>#attributes.KalendarRequest.getCategoryID()#</cfoutput>" />
			<select name="LinkDate" class="calendarSelectBoxes" onchange="changeWeek();">
				<cfloop index="LoopCount" from="-10" to="10">
				<cfset optionWeek = DateAdd('ww', LoopCount, attributes.KalendarRequest.getFirstDateOfWeek())>
				<cfif NOT LoopCount>
				<option selected="selected"><cfoutput>#DateFormat(attributes.KalendarRequest.getFirstDateOfWeek(), 'mmmm d, yyyy')#</cfoutput></option>
				<cfelse>
				<option><cfoutput>#DateFormat(OptionWeek, 'mmmm d, yyyy')#</cfoutput></option></cfif></cfloop>
			</select>
		</cfform>
		</div>
		
		<!--- CURRENT WEEK BUTTON --->
		<!--- <div id="currentButton">
		<cfif Week(Now()) neq Week(attributes.KalendarRequest.getLinkDate())>
		<cfform action="#cgi.SCRIPT_NAME#" method="post" id="viewweek">
			<input type="hidden" name="LinkDate" value="<cfoutput>#DateFormat(Now(), 'mmmm d, yyyy')#</cfoutput>" id="Link3Date" />
			<input type="hidden" name="categoryID" value="<cfoutput>#attributes.KalendarRequest.getCategoryID()#</cfoutput>" />
			<input type="hidden" name="view" value="<cfoutput>#attributes.view#</cfoutput>" />
			<input type="submit" name="submit" value=" current week " class="optionBarButton" />
		</cfform>
		</cfif>
		</div> --->
	</cfcase>
	
</cfswitch>
	<!--- CATEGORY SELECTOR --->
	<!--- <div id="categoryMenu">
	<cfform method="post" action="#cgi.script_name#" id="categoryChange">
		<input type="hidden" name="linkdate" value="<cfoutput>#attributes.KalendarRequest.getLinkDate()#</cfoutput>" id="linkdate" />
		<input type="hidden" name="view" value="<cfoutput>#attributes.view#</cfoutput>" />
		<select name="categoryID" onchange="document.getElementById('categoryChange').submit();">
			<cfoutput query="attributes.KalendarRequest.getCategoriesRS()">
			<option value="#categoryID#"<cfif attributes.KalendarRequest.getCategoryID() eq categoryID> selected</cfif>>#left(categoryName, 25)#</option>
			</cfoutput>
			<option value="0"<cfif attributes.KalendarRequest.getCategoryID() eq 0> selected</cfif>>all</option>
		</select>
	</cfform>
	</div> --->
	
	<!--- VIEW STATE SELECTOR --->
	<cfinclude template="viewStateSelector.cfm"/>
	
	<!--- preferences selector --->
	<cfif session.user.getUserID() NEQ "00000000-0000-0000-0000000000000000">
		<cfoutput>
			<a title="Preferences" href="#attributes.KalendarRequest.getKalendarConfig().getKalendarAdminPath()#?KeepThis=true&TB_iframe=true&height=150&width=300" class="thickbox">
				<img alt="Preferences" title="Preferences" src="#attributes.KalendarRequest.getKalendarConfig().getImagePath()#/server_edit.png" style="cursor:pointer; float:right;"/>
			</a>
			<a title="Add Event" href="#attributes.KalendarRequest.getKalendarConfig().getKalendarAdminPath()#index.cfm?appAction=addRecord&fromPublic=1&KeepThis=true&TB_iframe=true&height=395&width=425" class="thickbox">
				<img alt="Add Event" title="Add Event" src="#attributes.KalendarRequest.getKalendarConfig().getImagePath()#/calendar_add.png" style="cursor:pointer; float:right; padding-right:10px;"/>
			</a>
		</cfoutput>
	</cfif>
	
</div>
<!--- END: optionBar --->